package com.example.chao.component;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: WangYongChao
 * @Date: 2022/11/01/16:18
 * @Description: 定时任务
 */
@Component
public class ScheduledTasksUtil {

    private int count = 0;

    /**
     * 每3秒钟执行一次
     */
    @Scheduled(cron = "*/3 * * * * ?")
    public void scheduled() {
        System.out.println(count + "：" + (new Date()).toString());
        count++;
    }
}
